package router

import (
	"github.com/gin-gonic/gin"
	"starry_sky/api/handler"
	"starry_sky/internal/middleware/http-middleware"
)

// CustomizeRegister registers customize routers.
func customizedRegister(r *gin.Engine) {
	//{
	//	url := swagger.URL("http://localhost:8888/swagger/doc.json") // The url pointing to API definition
	//	r.GET("/swagger/*any", swagger.WrapHandler(swaggerFiles.Handler, url))
	//
	//}
	//无需验证权限
	{
		r.GET("/ping", handler.Ping)
	}
	//需权限验证
	{
		//所有需要权限验证的路由需要以/api作为开头
		api := r.Group("/api", http_middleware.JWTAuthMiddleware())
		{
			templateStructApi := api.Group("/templateStruct")
			{
				templateStructApi.POST("/create", handler.CreateOrUpdateTemplateStruct)
				templateStructApi.POST("/update", handler.CreateOrUpdateTemplateStruct)
				templateStructApi.POST("/find", handler.FindTemplateStructById)
				templateStructApi.POST("/page", handler.ListTemplateStructPage)
				templateStructApi.POST("/delete", handler.DeleteTemplateStruct)
				templateStructApi.POST("/generateStructForAll", handler.GenerateStructForAll)
			}
			loginLogApi := api.Group("/loginLog")
			{
				loginLogApi.POST("/page", handler.ListLoginLogPage)
			}
			handlerLog := api.Group("/handlerLog")
			{
				handlerLog.POST("/list", handler.GetSystemLogFileList)
				handlerLog.POST("/download", handler.DownloadSystemLogFile)
			}
			accessLog := api.Group("/accessLog")
			{
				accessLog.POST("/list", handler.GetAccessLogFileList)
				accessLog.POST("/download", handler.DownloadAccessLogFile)
			}
			serverMessage := api.Group("/serverMessage")
			{
				serverMessage.POST("/all", handler.GetServerMessage)
			}

		}
	}
}
